﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DataManager
{
    public partial class frmVasarlok : Form
    {
        frmKolcsonzesek m_frm;
        Customers m_Customers;

        public frmVasarlok(frmKolcsonzesek frm)
        {
            InitializeComponent();
            m_Customers = new Customers();
            m_frm = frm;
        }

        /// <summary>
        /// Szukit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSzukit_Click(object sender, EventArgs e)
        {
            dgvCustomers.Rows.Clear();
            List<Customer> customerList = m_Customers.GetCustomerList(tbFilter.Text);
            foreach (Customer item in customerList)
            {
                dgvCustomers.Rows.Add(item.CustomerId, item.CustomerName, item.Address, item.Email);
            }
        }

        /// <summary>
        /// Kivalasztja a vasarlot, majd visszaadja annak erteket a Kolcsonzesek tablanak
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnChoose_Click(object sender, EventArgs e)
        {
            m_frm.setCustomer(Convert.ToInt32(dgvCustomers.SelectedRows[0].Cells["VasarloId"].Value),dgvCustomers.SelectedRows[0].Cells["Nev"].Value.ToString());
            Hide();
            m_frm.Show();
            Close();
        }
    }
}
